# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=lxc-templates-legacy
pkgver=3.0.3
pkgrel=5
pkgdesc="Legacy LXC container templates"
url="https://linuxcontainers.org"
arch="noarch"
license="LGPL-2.1-or-later"
depends="bash tar"
subpackages="$pkgname-alpine"
source="https://linuxcontainers.org/downloads/lxc/lxc-templates-$pkgver.tar.gz
	0001-Update-alpine-keys-URI-fix-package-verification.patch
	0001-alpine-fix-arch-and-enable-mips64-and-s390x.patch
	0002-alpine-use-https-repository-by-default.patch
	0003-alpine-add-riscv64-key.patch
	0004-alpine-only-create-missing-device-node.patch
	"
builddir="$srcdir/lxc-templates-$pkgver"

prepare() {
 	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

alpine() {
	pkgdesc="$pkgdesc (for Alpine)"
	depends=
	mkdir -p "$subpkgdir"/usr/share/lxc/templates \
		"$subpkgdir"/usr/share/lxc/config
	local i; for i in templates/lxc-alpine config/alpine.userns.conf \
		config/alpine.common.conf; do
		mv $pkgdir/usr/share/lxc/$i "$subpkgdir"/usr/share/lxc/${i%/*}/
	done
}

sha512sums="
3e9d5304f5e06580eeb766570ddfebb0c80061c2d7e47c9ea37d834fe0cf4fabe7eedd667e4937df3f2451bc3e7aa1e98a1b386f3b19964dc218ff0e21011632  lxc-templates-3.0.3.tar.gz
70e3a7b0acd38b71b28c8a92896a7ef04a26cd9cef3f617056197edf2742344b1ec44e3d8d5ed6767a9a7c9c7af986300172f2cc15b9cc69ffbaf741a471f531  0001-Update-alpine-keys-URI-fix-package-verification.patch
0a34b0346fa5749e2d0e52cd68cede939c371668db07d0622275e3ec58b072059833236241d0c05a1df17997c2e6a021d48dabddb65b2d1e844bbcb45ca5c7a8  0001-alpine-fix-arch-and-enable-mips64-and-s390x.patch
7f90102df12aff63c0b8e38106ec30d309d6c0a2733b66d47b67f74b0bc8846b3d8eebb7b7cbd2f95ac724633357c06a36d8c69161db863f68dc4c023ad96137  0002-alpine-use-https-repository-by-default.patch
5036df735f6fa35593516d63a46a1cc398651ee1a6426d2f12397d211deac16e8c587b701df13d46e7d3251b3d0a48d63b8422af92a8e4874ebda045b328d20b  0003-alpine-add-riscv64-key.patch
20106603e9d3f73759469ebba5c44196a4f6091f414139e30dc4a5f12a3dc9220aa4301dd274a4ca50edef3cec3545f1406b2505be70d5a3496c233a9f9438fb  0004-alpine-only-create-missing-device-node.patch
"
